//
//  AudioStreamerManager.m
//  TingBook
//
//  Created by qiYue on 14/11/15.
//  Copyright (c) 2014年 七月. All rights reserved.
//

#import "AudioStreamerManager.h"
static AudioStreamerManager *manager = nil;

@implementation AudioStreamerManager

+ (AudioStreamerManager *)shareInstanceManager
{
    
    if (manager != nil) {
        return manager;
       
    }
    
    manager = [[AudioStreamerManager alloc] init];
    return manager;
}

//
//-(instancetype)init
//{
//    self = [super init];
//    if (self) {
//
//        
//    }
//    return self;
//    
//}
-(void)playWithData:(NSMutableArray *)data num:(NSInteger)num model:(SortingModel *)model
{
    if ([_Mymodel.playUrl32 isEqualToString:model.playUrl32]) {
        
        
    }
    else
    {
        if (self.PLAYER != nil) {
            [self.PLAYER pause];
            self.PLAYER = nil;
            
        }
        
        self.PLAYER = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:model.playUrl32]];
        self.Mydata = [NSMutableArray arrayWithArray:data];
        self.num = num;
        self.Mymodel = model;
//        self.flag = YES;
        
        [self.PLAYER play];
        AVAudioSession *session = [AVAudioSession sharedInstance];
        [session setActive:YES error:nil];
        [session setCategory:AVAudioSessionCategoryPlayback error:nil];
}
}
-(void)pause
{
    [self.PLAYER pause];
//    self.flag = NO;
    
}

@end
